using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;

namespace ParticleSystem.Particles
{
    public class Projectile
    {
        ParticleSystem particleSystem;
        Vector3 position;
        Vector3 velocity;
        float age;

        const float MAX_AGE = 5f;

        public Projectile(ParticleSystem particleSystem, Vector3 position, Vector3 velocity)
        {
            this.particleSystem = particleSystem;
            this.position = position;
            this.velocity = velocity;
            age = 0;
        }

        public Boolean Update(GameTime gameTime)
        {
            age += (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (age > MAX_AGE)
            {
                return true;
            }

            position += velocity;

            particleSystem.AddParticle(position, velocity);

            return false;
        }
    }
}
